package com.scorpio.basic.service.impl;

import java.util.Arrays;
import java.util.List;

import com.scorpio.basic.service.IHomeListResService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.scorpio.basic.mapper.HomeListMapper;
import com.scorpio.basic.domain.HomeListEntity;
import com.scorpio.basic.service.IHomeListService;
import com.scorpio.common.service.impl.BaseServiceImpl;
import org.springframework.transaction.annotation.Transactional;

/**
 * 首页列数据Service业务层处理
 *
 * @author scorpio
 * @date 2021-11-16
 */
@Service
public class HomeListServiceImpl extends BaseServiceImpl<HomeListMapper, HomeListEntity> implements IHomeListService {

    @Autowired
    private IHomeListResService resService;

    //查询
    @Override
    public HomeListEntity selectById(Long id) {
        return baseDao.selectById(id);
    }

    //查询列表
    @Override
    public List<HomeListEntity> selectList(HomeListEntity entity) {
        return baseDao.list(entity);
    }

    //新增$
    @Transactional(rollbackFor = Exception.class)
    @Override
    public int save(HomeListEntity entity) {
        int count = baseDao.insert(entity);
        if (count > 0) {
            resService.initBtHomeList(entity.getId());
        }
        return count;
    }

    //修改$
    @Transactional(rollbackFor = Exception.class)
    @Override
    public int update(HomeListEntity entity) {
        return baseDao.updateById(entity);
    }

    //批量删除
    @Transactional(rollbackFor = Exception.class)
    @Override
    public int deleteByIds(Long[] ids) {
        return baseDao.updateDelete(ids);
    }
}
